package org.hanbo.code.repository.persistence;

import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

public class DAOBase
{
	private PersistenceManager pm;

	public DAOBase()
	{ }

	public void acquirePersistenceManager()
	{
		PersistenceManagerFactory pmf = PersistenceManagerFactoryInstance.getInsatnce();
		pm = pmf.getPersistenceManager();
	}
	
	public void releasePersistenceManager()
	{
		if (pm != null)
		{
			pm.close();
			pm = null;
		}
	}
	
	protected PersistenceManager getPersistenceManager()
	{
		return pm;
	}
	
	protected boolean isPersistenceManagerAcquired()
	{
		return (pm != null && !pm.isClosed());
	}
}